<?php

class WSB_Model_Gateway
{

	/**
	 * The database adapter
	 *
	 * @var Zend_Db_Adapter_Abstract
	 */
	protected $_db;

	/**
	 * @var boolean
	 */
	protected $_usePaginator = false;

	/**
	 * @var boolean
	 */
	protected $_useModels = false;

	/**
	 * Constructor
	 */
	public function __construct()
	{
		$this->_db = Zend_Db_Table_Abstract::getDefaultAdapter();
		$this->init();
	}

    /**
     * Initialize object
     *
     * Called from {@link __construct()} as final step of object instantiation.
     *
     * @return void
     */
    public function init()
    {
    }

    /**
     * @return Zend_Db_Adapter_Abstract
     */
    public function getDb()
    {
    	return $this->_db;
    }

    /**
     * @return Zend_Db_Select
     */
    public function getDbSelect()
    {
    	return $this->_db->select();
    }

    /**
     * Set flag indicating whether or not to use paginator
     *
     * @param  bool $flag
     * @return Spindle_Model_Paste
     */
    public function setUsePaginator($flag)
    {
        $this->_usePaginator = (bool) $flag;
        return $this;
    }

    /**
     * Use a paginator?
     *
     * @return bool
     */
    public function usePaginator()
    {
        return $this->_usePaginator;
    }

	/**
	 * @param boolean $flag
	 */
	public function setUseModels($flag)
	{
		$this->_useModels = $flag;
	}

	/**
	 * @return boolean
	 */
	public function useModels()
	{
		return $this->_useModels;
	}

	/**
	 * @param string $table
	 * @param array $data
	 * @param mixed $where
	 * @return integer Number of affected rows
	 */
	public function update($table, array $data, $where)
	{
		$db = $this->getDb();
		return $db->update($table, $data, $where);
	}

}
